# -*- coding:utf-8 -*-

import sys
import time

import pygame
from ba4988 import BA4988


def update(striped):
    screen = pygame.display.set_mode(striped.shape)
    clock = pygame.time.Clock()
    while 1:
        for event in pygame.event.get():
            if event.type == pygame.KEYUP:
                if event.key ==pygame.K_ESCAPE:
                    return
            elif event.type == pygame.QUIT:
                return
        pygame.surfarray.blit_array(screen, striped)
        clock.tick(30)
        pygame.display.update()


def main():
    pygame.init()
    pygame.display.set_caption('BA4988')

    ba4988 = BA4988()
    # ba4988.x6502.PC = 0x852A  # SysPutPixel
    # ba4988.x6502.A = 8  # x
    # ba4988.memory[0x0C20] = 0x00
    # ba4988.flash[0x17AF] = 0  # y
    # ba4988.flash[0x17B0] = 1  # data
    ba4988.start()
    update(ba4988.display)
    ba4988.stop()

    # alldone
    pygame.quit()


if __name__ == '__main__':
    main()
